package com.example.tepthydjl;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBar;

import com.tepth.remote.control.base.bean.NotificationBean;
import com.tepth.remote.control.delegate.apply.examination.ExaminationDelegate;
import com.tepth.remote.control.delegate.apply.notify.NotifyDelegate;
import com.tepth.remote.control.delegate.launcher.LauncherDelegate;
import com.tepth.remote.control.manager.ControlNotificationManager;
import com.tepth.remote.core.activity.BaseProxyActivity;
import com.tepth.remote.core.delegates.BaseControlDelegate;

/**
 * @author Hequn.Lee
 * @date 2018/11/8
 */
public class MainActivity extends BaseProxyActivity {

    @Override
    public BaseControlDelegate setLauncherDelegate() {
        return new LauncherDelegate();
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        final ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.hide();
        }
    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        if (intent.getParcelableExtra(ControlNotificationManager.NOTIFICATION_NAME) != null) {
            final NotificationBean bean = intent.getParcelableExtra(ControlNotificationManager.NOTIFICATION_NAME);
            switch (bean.getType()) {
                case 1:
                    final Bundle bundle = new Bundle();
                    bundle.putInt(ExaminationDelegate.TARGET, bean.getTargetId());
                    bundle.putString(ExaminationDelegate.CONTEXT, bean.getContext());
                    start(ExaminationDelegate.create(bundle));
                    break;
                case 2:
                case 3:
                    start(NotifyDelegate.create(bean.getType(), bean.getContext()));
                    break;
                default:
                    break;
            }
        }
    }
}
